package com.bc.bczbweb.controller;

import com.bc.bcapi.service.T_Role_infoService;
import com.bc.bccore.util.PageHelper;
import com.bc.bcmodel.domain.T_Role_infoModel;
import com.bc.commoncore.security.AES;
import com.bc.commoncore.util.StringUtils;
import com.bc.commonentity.common.JsonResult;
import com.bc.bcapi.service.T_Mnguser_infoService;
import com.bc.bcmodel.domain.T_Mnguser_infoModel;
import com.bc.commonentity.common.PagedResponse;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.math.BigInteger;

@Controller
@RequestMapping("t_mnguser_info")
public class T_Mnguser_infoController extends BaseController {
    @Autowired
    T_Mnguser_infoService t_Mnguser_infoService;

    @Autowired
    T_Role_infoService t_Role_infoService;

    @RequestMapping("list")
    public ModelAndView list() {
        ModelAndView view = super.baseView("列表", "t_mnguser_info/list");
        return view;
    }

    @RequestMapping(value = "listdo", method = RequestMethod.POST)
    public ModelAndView listdo(T_Mnguser_infoModel req) {
        ModelAndView view = super.baseViewAjax("列表", "t_mnguser_info/listdo");

        PageInfo<T_Mnguser_infoModel> pageList = t_Mnguser_infoService.getList(req);
        T_Role_infoModel roleModel = new T_Role_infoModel();
        roleModel.setStatus("1");//正常状态
        view.addObject("role_data", t_Role_infoService.getAllList(roleModel));

        view.addObject("data", pageList.getList());
        view.addObject("page", PageHelper.GetAjaxHtml(
                pageList, "javascript:searchUser(##);"));
        return view;
    }

    @RequestMapping("add")
    public ModelAndView add(String user_id) {
        String title = "添加";
        ModelAndView view = super.baseView(title, "t_mnguser_info/add");
        T_Mnguser_infoModel model = new T_Mnguser_infoModel();
        model.setUser_id(user_id);
        if (!user_id.equals("")) {
            title = "编辑";
            model = t_Mnguser_infoService.findByNamedParam(model);
            if (!model.getPassword().equals("")) {
                model.setPassword(AES.aesDecrypt(model.getPassword()));
            }
        }
        T_Role_infoModel roleModel = new T_Role_infoModel();
        roleModel.setStatus("1");//正常状态
        view.addObject("role_data", t_Role_infoService.getAllList(roleModel));
        view.addObject("data", model);
        view.addObject("title", title);
        return view;
    }

}